package cn.keepme.ep.user.service.impl;
import cn.keepme.ep.user.service.FUserQuizServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import cn.keepme.ep.user.entity.FUserQuizEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;
import java.io.Serializable;

@Service("fUserQuizService")
@Transactional
public class FUserQuizServiceImpl extends CommonServiceImpl implements FUserQuizServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((FUserQuizEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
 		this.doAddSql((FUserQuizEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
 		this.doUpdateSql((FUserQuizEntity)entity);
 	}
 	
 	/**
 	 * 数据查询操作
 	 */
 	public List<FUserQuizEntity> querySql(FUserQuizEntity t){
 		
 		return this.querySql(t);
 	}
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(FUserQuizEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(FUserQuizEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(FUserQuizEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,FUserQuizEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{type}",String.valueOf(t.getType()));
 		sql  = sql.replace("#{email}",String.valueOf(t.getEmail()));
 		sql  = sql.replace("#{nickname}",String.valueOf(t.getNickname()));
 		sql  = sql.replace("#{job}",String.valueOf(t.getJob()));
 		sql  = sql.replace("#{create_datetime}",String.valueOf(t.getCreateDatetime()));
 		sql  = sql.replace("#{valid_date}",String.valueOf(t.getValidDate()));
 		sql  = sql.replace("#{active_datetime}",String.valueOf(t.getActiveDatetime()));
 		sql  = sql.replace("#{is_active}",String.valueOf(t.getIsActive()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}
}